<template>
	<div class="wrapper customer-box" >
		<el-tabs v-model="innerIndex" type="card" @tab-click="handleClick">
		    <el-tab-pane label="趋势" name="0"></el-tab-pane>
		    <el-tab-pane label="推广日志" name="1"></el-tab-pane>
		</el-tabs>
		<nuxt-child/>
	</div>
</template>

<script>
	import Vue from 'vue'
	import {Tabs,TabPane} from 'element-ui';
	import { INNER_INDEX } from '../../store/mutation-types/promotionLink/index.js'
  	import { mapGetters} from 'vuex';
  	
	Vue.use(Tabs);
	Vue.use(TabPane);
	
	export default {
		components: {
			
		},
		head() {
			return {
				title: this.title,
			}
		},
		data() {
			return {
				title:'趋势'	,
				tabName:'趋势'
			}
		},


		computed: {
			...mapGetters({
				'innerIndex' : 'getInnerIndex',
				'pageTabsList': 'getPageTabsList'
			})
		},
		methods: {
			handleClick(tab, event) {
		        this.$router.push('/b2cAdmin/promotionLink/'+ tab.name)
		        this.$store.commit(INNER_INDEX, { innerIndex: tab.name});
		    },
		    changeTabs(){
		        if (!process.BROWSER_BUILD) {
		            return false;
		          }
		          let url = window.location.href;
		          url = url.substring(url.lastIndexOf("/"));
		          let tab = url.charAt(1);
		          switch (tab){
		              case '1':
		                  this.$store.commit(INNER_INDEX, { innerIndex: '1'});
		                  break;
		              default:
		                  this.$store.commit(INNER_INDEX, { innerIndex: '0'});
		          }
		      },
		},
		created() {
			//pageTab
			if(process.BROWSER_BUILD) {
				if(this.pageTabsList[this.pageTabsList.length - 1].name == 'CRM') {
					let arr = this.pageTabsList;
					arr[arr.length - 1].name = this.tabName;
					this.$store.commit('PAGETABSLIST', {
						data: arr
					})
				}
			}
		},
		mounted() {
			this.changeTabs()
		}
	}
</script>

<style lang="scss">
</style>